package cn.tedu.rabbitmqspring.m2;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Scanner;

@Component
public class Producer {


    @Autowired
    private AmqpTemplate t;

    //生产者的发送方法 需要手动调用
    //实现自动的分发  默认是手动确认, qos =1 每次抓取一个

    public void send(){

        while (true){
            System.out.println("输入消息：");
            String s = new Scanner(System.in).nextLine();
            //自动转成byte[]数组再发送
            t.convertAndSend("task_queue",s);
        }

    }




}
